import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

const store = new Vuex.Store({
  strict: false,  // process.env.NODE_ENV !== 'production',
  actions: {},
  modules: {},
  state: {
    remUnit: 75,
  },
  getters: {
    rootFontSize: (state, getters) => {
      if (getters.isPC) {
        let clientWidth = document.documentElement.clientWidth;
        return clientWidth / 10;
      } else {
        return state.remUnit;
      }
    },
    pxToRem: (state) => (px) => {
      return px / state.remUnit;
    },
    isPC() {
      let userAgentInfo = navigator.userAgent;
      let Agents = ["Android", "iPhone",
        "SymbianOS", "Windows Phone",
        "iPad", "iPod"];
      let flag = true;
      for (let v = 0; v < Agents.length; v++) {
        if (userAgentInfo.indexOf(Agents[v]) > 0) {
          flag = false;
          break;
        }
      }
      return flag;
    }
  },
  mutations: {
    setInfo(state, {applicationId, userId}) {
      state.applianceId = applicationId;
      state.userId = userId;
    },
    updateStatus(state) {
      // 变更状态

    }
  },
  action: {}
});

export default store;
